﻿<%@ WebHandler Language="VB" Class="GetImage" %>

Imports System
Imports System.Web


Public Class GetImage : Implements IHttpHandler
    
    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
        
        Dim imgPath As String = context.Request.Params("path")
        Dim height As Int32 = Int32.Parse(context.Request.Params("height"))
        Dim width As Int32 = Int32.Parse(context.Request.Params("width"))
        
        
        context.Response.ContentType = "image/jpeg"
        
        
        Dim MS As New System.IO.MemoryStream
        Dim Img As System.Drawing.Image = System.Drawing.Image.FromFile(Config.ImageFolder + imgPath, True)
        ImageHelper.ImageResize.FixedSize(Img, width, height).Save(MS, Img.RawFormat)
        Dim buffer() As Byte = MS.ToArray
        context.Response.OutputStream.Write(buffer, 0, buffer.Length)
        
       
    End Sub
 
    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
        Get
            Return False
        End Get
    End Property

End Class